<template>
  <el-input-number
    v-model="val"
    :min="min"
    :max="max"
    :step="step"
    :step-strictly="stepStrictly"
    @change="change"
    :size="size"
  ></el-input-number>
</template>

<script>
export default {
  name: "EinputNumber",
  props: {
    // 最小值
    min: {
      type: Number,
      default: 0,
    },
    // 最大值
    max: {
      type: Number,
      default: 9999,
    },
    // 步数
    step: {
      type: Number,
      default: 1,
    },
    // 步数严格限制
    stepStrictly: {
      type: Boolean,
      default: true,
    },
    // 绑定的值
    value: {
      type: Number,
    },
    size: {
      type: String,
      default: "small",
    },
  },
  watch: {
    value: {
      handler(newVal) {
        this.val = newVal;
      },
      immediate: true,
    },
  },
  data() {
    return {
      val: 0,
    };
  },
  methods: {
    // 值改变
    change(val) {
      this.$emit("input", val);
    },
  },
};
</script>

<style lang="scss" scoped></style>
